
export default class Observer{
    constructor(){
        this.arr = [];
    }

    // 订阅
    addSubscriber(cb){
        this.arr.push(cb);
    }

    // 发布
    publish(what){
        this.arr.forEach(item=>{
            typeof item==="function" && item(what);
        })
    }

}